package com.campus.commons.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.Date;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 消息【一些通知消息】表
 * </p>
 *
 * @author Rin
 * @since 2021-01-25
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="Notification对象", description="消息【一些通知消息】表")
public class Notification implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "信息类型")
    private Integer infoType;

    @ApiModelProperty(value = "通知的目标")
    @TableField("userId")
    private Integer userId;

    @ApiModelProperty(value = "是否已读 0未读，1已读")
    @TableField("isRead")
    private Boolean isRead;

    @ApiModelProperty(value = "消息内容")
    private String content;
    @TableField("createTime")
    private Date date;
    @TableField(exist = false)
    private NotificationType type;

    public void setInfoType(Integer infoType) {
        this.infoType = infoType;
        this.type = NotificationType.types.get(infoType);
    }
}
